package builderpattern;

import builderpattern.builder.Builder;
import builderpattern.builder.impl.CommonHouseBuilder;
import builderpattern.builder.impl.HighBuildingBuilder;
import builderpattern.house.AbstractHouse;
import builderpattern.house.extend.House;

/**
 * @author : DuJiabao
 * @Date : 2021/3/2 10:23
 * @Project : design-pattern
 * @File : null.java
 * @Desc :
 */
public class HouseDirector {
  private Builder builder;

  public HouseDirector() {
  }

  public HouseDirector(Builder builder) {
    this.builder = builder;
  }

  public void setBuilder(Builder builder) {
    this.builder = builder;
  }

  public AbstractHouse constructHouse() {
    builder.buildBasic();
    builder.buildWalls();
    builder.roofed();
    return builder.build();
  }

  public static void main(String[] args) {
    HouseDirector houseDirector = new HouseDirector(new CommonHouseBuilder());
    AbstractHouse house = houseDirector.constructHouse();
    System.out.println(house);
    houseDirector.setBuilder(new HighBuildingBuilder());
    house = houseDirector.constructHouse();
    System.out.println(house);
  }
}
